package cc.lishixi.tdd;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.*;

/**
 * 假设演示
 *
 * @author LiShixi 2020/12/27 5:01 下午
 * @email loyy77@163.com
 */
public class AssumptionsDemo {
    Calc calc = new Calc();

    @BeforeEach
    public void up() {
        System.setProperty("ENV", "DEV");
    }

    @Test
    public void testAdd() {
        Assumptions.assumeTrue("DEV".equals(System.getenv("ENV")), () -> {
            final int add = calc.add(1, 2);
            Assertions.assertThat(3).isEqualTo(add);
            return "";
        });
    }

    @Test
    public void testAdd1() {
        Assumptions.assumeTrue("DEV".equals(System.getenv("ENV")));
        final int add = calc.add(1, 2);
        Assertions.assertThat(3).isEqualTo(add);
        Assertions.assertThat(2).isEqualTo(calc.add(1,1));
    }
    @Test
    public void testAdd2() {
        Assumptions.assumingThat("CI".equals(System.getenv("ENV")),() -> {
            Assertions.assertThat(3).isEqualTo(calc.add(1, 2));
        });
        Assertions.assertThat(2).isEqualTo(calc.add(1,1));
    }
    @Test
    @Disabled("#33 号bug还没有修复")
    public void testAdd3() {

        Assertions.assertThat(2).isEqualTo(calc.add(1,1));
    }
}
